/*
 *  Cero Project - Copyright   2006 The Cero Developement Team 
 *  (Michael Laguerre, Camille Roux, Matthieu Segret, Mathieu Sivade) 
 * 
 *  This program is free software; you can redistribute it and/or modify it 
 *  under the terms of the GNU General Public License as published by the Free 
 *  Software Foundation; either version 2 of the License, or (at your option) 
 *  any later version.
 * 
 *  This program is distributed in the hope that it will be useful, but 
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 *  for more details.
 */

package org.ceroproject.games.base;

import java.util.ArrayList;

import org.ceroproject.games.Card;


public class Card52 extends CardBase {
	static private String values[] = { null, "As", "2", "3", "4", "5", "6",
			"7", "8", "9", "Valet", "Dame", "Roi" };

	static private String colors[] = { "Pique", "Trefle", "Coeur", "Carreau" };

	static private String linkWord = " de ";

	public static final int PIQUE = 0;

	public static final int TREFLE = 1;

	public static final int COEUR = 2;

	public static final int CARREAU = 3;

	private int value;

	private int color;

	private String name;

	private boolean isHidden;

	public Card52(int value, int color) {
		this.value = value;
		this.color = color;
		this.isHidden = false;
	}

	private Card52(int id) {
		super(id);
	}

	public String getCardName() {
		if (name == null)
			name = values[value] + linkWord + colors[color];
		if (isHidden)
			return "Cach�e";
		return name;
	}

	public Card getHiddenCard() {
		Card52 hiddenCard = new Card52(super.getCardId());
		hiddenCard.isHidden=true;
		return hiddenCard;
	}

	public boolean isHiddenCard() {
		return isHidden;
	}

	public static ArrayList<Card52> getCardSet() {
		ArrayList<Card52> cardSet = new ArrayList<Card52>();
		for (int i = 1; i < values.length; i++) {
			for (int j = 0; j < colors.length; j++) {
				cardSet.add(new Card52(i, j));
			}
		}
		return cardSet;
		
		//this code is used to test games with very few cards
		/*cardSet.add(new Card52(1,1));
		cardSet.add(new Card52(1,2));
		return cardSet;*/
	}

	public String getCardSetName() {
		return "52";
	}

	public int getColor() {
		return color;
	}

	public int getValue() {
		return value;
	}
	
	public String toString() {
		return getCardName() + " : " + getCardId();
	}

}
